thinkphp6 paginate() 分页数据处理后输出://model里面的分页函数 public function pageQuery(){ $rs = $this->where($where)->field(true)->order('id desc')->paginate() ->each(function($item, $key){ if($item['status']==1){ $item['name1'] = $item['name2']; } $item['imgSize'] = round($item['imgSize']/1024/1024,2); return $item; }); return $rs; }
知识技术 1335
Unsupported operand types报错的解决方法,把2个数组相加,如:$rs[] = $mainRs + $awayTeamArray;原因是tp6的Db::name(table)->find()出来赋值给变量$awayTeamArray,而此时$awayTeamArray不是数组,解决方法是,给他转成数组格式,正确代码如下:$rs[] = (array)$mainRs + (array)$awayTeamArray;
知识技术 2652
thinkphp6:模板注释及原样输出,原样输出模板标签:可以使用literal标签来防止模板标签被解析,​上面的{$name}标签被literal标签包含,因此并不会被模板引擎解析,而是保持原样输出
知识技术 1039
thinkphp6报错:Argument 1 passed to think\db\Query::getFieldType() must be of the type string, int given的解决方法:粗心了吧:把insert改为:insertAll即可
知识技术 3211
nginx里有https的网站也有http的网站,http的站如果加https总是跳到其他站的解决方法,如:我现在有2个站点,https://www.a.com和http://www.b.com,当我把不是https的站也用https请求的时候,就会跳转到https的那个源码。比如我打开https://www.b.com(用https的方式请求http的网站)就会显示https://www.a.com的源码
知识技术 1551
wordpress自动生成sitemap网站地图的代码,无须插件:把下面代码文件命名为:sitemap.php,然后做伪静态为:sitemap.xml,然后在宝塔里设置定期刷新sitemap即可:
知识技术 1154
wordpress禁用gravatar并用默认头像替换等小问题处理:开启wordpress友情链接管理,移除登录页面标题中的“ — WordPress”,注册登录后返回网站首页
知识技术 1344
wordpress统计文章评论数功能,把如下代码放到模板所在目录的functions.php里即可: * 单篇文章调用:echo comments_users($post->ID); * 统计全站评论数:echo comments_users($postid, 1);
知识技术 1161
wordpress获取热门文章的功能代码:global $wpdb; $today = date("Y-m-d H:i:s"); //获取今天日期时间 $daysago = date( "Y-m-d H:i:s", strtotime($today) - ($days * 24 * 60 * 60) ); $sql = "SELECT comment_count,ID,post_title "; $sql .= "FROM $wpdb->posts where post_status='publish' and post_type='post' "; $sql .= " and post_date BETWEEN '$daysago' AND '$today' "; $sql .= "ORDER BY comment_count DESC "; $sql .= "LIMIT 0 , $num"; $hotposts = $wpdb->get_results($sql);
知识技术 1633
wordpress更改固定连接URL后做301重定向的代码:更改内页url规则后,做内页301重定向到新url。wordpress更改固定连接URL后做301重定向到新的URL,把如下代码放到模板所在目录的functions.php里即可:
知识技术 1181
共 15 页 149 条数据
在线客服